<?php

declare(strict_types=1);

namespace App\Fastapp\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $user_id 用户id
 * @property string $title 标题
 * @property string $content 内容
 * @property int $object_id 数据id
 * @property int $object_type 类型1充值2提现
 * @property int $status 0未读1已读
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 更新时间
 */
class AccountMessage extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'account_message';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'user_id', 'title', 'content', 'object_id', 'object_type', 'status', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'object_id' => 'integer', 'object_type' => 'integer', 'status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function log(): HasOne
    {
        return $this->hasOne(AccountWalletLog::class, 'id', 'object_id');
    }
}
